<?php

namespace app\api\controller;

use think\facade\Request;

class Mobile
{
    /**
     * 手机号录入
     */
    public function create()
    {
        $post = Request::post();
        $reg = "/^[1][3,4,5,7,8,9][0-9]{9}$/";
        if(!preg_match($reg, $post['mobile'])){
            return result(1, '手机号格式错误');
        }
        try{
            (new \app\admin\model\Promote())->save($post);
        }catch (\Exception $e){
            return result(1, '录入出错：'.$e->getMessage());
        }
        return result(0, '录入成功');
    }
}